/*
 * @LastEditors: 杜康
 * @LastEditTime: 2021-12-27 10:26:32
 */
import { createRouter, createWebHistory } from 'vue-router'
// import
import Home from '../components/Home.vue'
import About from '../components/About.vue'
import TailwindStart from '../components/Tailwind-Start.vue'
import Login from '../components/modules/login/login.vue'
import MainMenu from '../components/MainMenu.vue'
import ThreeJs from '../components/Three-Js.vue'

const routes = [
  { path: '/', name: 'Login', component: Login },
  {
    path: '/mainMenu',
    name: 'MainMenu',
    component: MainMenu,
    children: [
      { path: '/mainMenu/home', name: 'Home', component: Home },
      { path: '/mainMenu/about', name: 'About', component: About },
      { path: '/mainMenu/tailwindStart', name: 'TailwindStart', component: TailwindStart },
      { path: '/mainMenu/threejs', name: 'Threejs', component: ThreeJs }
    ]
  }
]
const router = createRouter({
  history: createWebHistory(),
  routes
})
router.beforeEach((to, from, next) => {
  next()
  // console.log('🚀 ~ router.beforeEach ~ from', from)
  // console.log('🚀 ~ router.beforeEach ~ to', to)
  // if (!localStorage.getItem('passAuth')) {
  //   next('/')
  // } else {
  //   next()
  // }
  // if (to.fullPath !== '/') {
  //   if (to.params.userName === 'Mistic' && to.params.userPwd === 'milet') {
  //     localStorage.setItem('passAuth', true)
  //     next()
  //   } else {
  //     next('/')
  //   }
  // } else {
  //   next('/')
  // }
})
export default router